var validation=new function(){
	
	
	this.notNull=function(){
		var valid=true;
		var msg="";
		var focusObject;
		$("div[id='erpPopUp'] [notNull]").each(function(){
									   var value;
									   var tagName=$(this).prop("tagName");
							 
								   if(tagName==="SELECT" && valid==true){
								 
									   value=$(this).val();
							 
									   if(value==="-1"){
									   alert($(this).attr("name"))
										   valid=false;
										   
									   msg=$(this).attr("msg");
									   focusObject=$(this);
										   }
								 
									   }
									   if(tagName==="INPUT" && valid==true){
									    value=$(this).val().trim();
								   if(value.length==0){
									   valid=false;
									   msg=$(this).attr("msg");
									   focusObject=$(this);
									   }
									   }
								  
								   
								   
								   
								   });
 
		if(!valid){
			
		 	var msgContainer = document.createElement("div");
				msgContainer.id = "errorAlert";
				msgContainer.title = 'Error';
				document.body.appendChild(msgContainer);
		 		$("#errorAlert").addClass("ui-state-error ui-corner-bottom"); 
				var appendText='<p><span class="ui-icon ui-icon-alert" style="float: left; margin:30px; "></span><div style="margin:30px;"><strong> '+msg+'</strong></div></p>';
				 $("#errorAlert").append(appendText);
				 $("#errorAlert").dialog({ 
			 		autoOpen: true,
					resizable:false,
					modal :true,				
					close:function(event,ui){
							$(this).dialog("close").remove();
						 $(focusObject).focus();
						}
				 
			});
							$("#errorAlert").prev('.ui-dialog-titlebar').removeClass("ui-corner-all");
				$("#errorAlert").prev('.ui-dialog-titlebar').addClass("ui-corner-top");
				
			}else{
				$('input[type=text]').val (function () {
				    return this.value.toUpperCase();
				});
				}

			   
		return valid;
		
		}
	
	
	this.saveUpdate=function(actionName,formName){
		 $("*:disabled").prop("disabled",false); 
		 var formSubmit="div[id='erpPopUp'] form[name='"+formName+"']";
			 $.post( actionName, $(formSubmit).serialize() ).done(function(data){
			 try{
		closeDialog();
			 }catch(e){};												$("div[id='loadData']").html(data);
																	
																													});
			 
			 }
		
		}
	
	
	
	
